RAIS  3.2
C:/Projekte/RAIS/UI Common/SearchManagement.cs
Go to the documentation of this file.
00001 
00028 using System;
00029 using System.Collections.Generic;
00030 using System.Text;
00031 using System.Web.UI;
00032 using System.Web.UI.WebControls;
00033 
00034 using RAIS.Common;
00035 
00036 namespace RAIS.UI.Common
00037 {
00041     public class SearchManagement
00042         {
00043 
00044                 public static Dictionary<string, string> GetSearchItems(Page page, bool reset)
00045                 {
00046                         string tagName = RAIS.UI.Common.Constants.SEARCH_ITEMS_TAG;
00047                         Dictionary<string, string> searchItems = new Dictionary<string, string>();
00048 
00049                         if (reset)
00050                                 page.Session[tagName] = null;
00051 
00052                         if (page.Session[tagName] == null)
00053                         {
00054                                 searchItems = RAIS.ApplicationLogicLayer.SearchManagement.GetSearchItems();
00055                                 page.Session[tagName] = searchItems;
00056                         }
00057                         else
00058                         {
00059                                 searchItems = (Dictionary<string, string>)page.Session[tagName];
00060                         }
00061 
00062                         return searchItems;
00063                 }
00064 
00065                 public static void InitializeSearchItems(DropDownList list)
00066                 {
00067                         Dictionary<string, string> searchItems = GetSearchItems(list.Page, true);
00068 
00069                         string[] searchItemsNames = new string[searchItems.Count];
00070                         searchItems.Keys.CopyTo(searchItemsNames, 0);
00071 
00072                         UI.Common.Controls.InitializeList(list.Items, searchItemsNames);
00073 
00074                         // Selected search item could be empty, so add empty row
00075                         list.Items.Insert(0, new ListItem(string.Empty, 0.ToString()));
00076                 }
00077 
00078                 public static Dictionary<string, SearchDefinition> GetSearchDefinitionsBySearchItem(Page page, string searchItem, bool reset)
00079                 {
00080                         string tagName = RAIS.UI.Common.Constants.SEARCH_DEFINITIONS_TAG;
00081                         Dictionary<string, SearchDefinition> searchDefinitions = new Dictionary<string, SearchDefinition>();
00082 
00083                         if (reset)
00084                                 page.Session[tagName] = null;
00085 
00086                         if (page.Session[tagName] == null)
00087                         {
00088                                 searchDefinitions = RAIS.ApplicationLogicLayer.SearchManagement.GetSearchDefinitionsBySearchItem(searchItem);
00089                                 page.Session[tagName] = searchDefinitions;
00090                         }
00091                         else
00092                         {
00093                                 searchDefinitions = (Dictionary<string, SearchDefinition>)page.Session[tagName];
00094                         }
00095 
00096                         return searchDefinitions;
00097                 }
00098 
00099                 public static void InitializeSearchDefinitionsBySearchItem(DropDownList list, string searchItem)
00100                 {
00101                         Dictionary<string, SearchDefinition> searchDefinitions = GetSearchDefinitionsBySearchItem(list.Page, searchItem, true);
00102 
00103                         string[] searchDefinitionsNames = new string[searchDefinitions.Keys.Count];
00104                         searchDefinitions.Keys.CopyTo(searchDefinitionsNames, 0);
00105 
00106                         UI.Common.Controls.InitializeList(list.Items, searchDefinitionsNames);
00107 
00108                         // Selected search definition could be empty, so add empty row
00109                         list.Items.Insert(0, new ListItem(string.Empty, 0.ToString()));
00110                 }
00111         }
00112 }